var member_ops = {
    init: function () {
        this.eventBind();
    },
    eventBind: function () {
        $('.save').click(function (ev) {
            ev.preventDefault();
            var nickname_i = $('.nickname_input');
            var nickname = nickname_i.val();
            var id = nickname_i.attr('data-id');
            if (nickname == null || nickname.length < 1) {
                common_ops.tip('请输入会员名称', nickname_i);
                return;
            }

            $.ajax({
                url: '/member/set/',
                type: 'POST',
                dataType: 'json',
                data: {
                    'id': id,
                    'nickname': nickname
                },
                success: function (data) {
                    if (data['code'] === 200) {
                        window.location.href = '/member/index';
                    }
                    else {
                        common_ops.alert(data['msg']);
                    }
                },
                fail: function () {
                    common_ops.alert("数据提交失败，请重试！");
                }
            });
        });
    }
};

$(function () {
    member_ops.init();
});